﻿using System;
using System.Linq;
using Tasks247.Data;
using Tasks247.Model;

namespace Tasks247.Views
{
    public class DeleteTaskView
    {
        public DeleteTaskView(ITasksRepository repository)
        {
            TaskEntity taskToDelete = repository.Read().FirstOrDefault();
            if (taskToDelete != null)
            {
                repository.Delete(taskToDelete.Id);
                Console.WriteLine("Task {0} deleted", taskToDelete.Id);
            }
            else
            {
                Console.WriteLine("No records to delete...");
            }
        }
    }
}